home *** CD-ROM | disk | FTP | other *** search
/ The Charlie Rose Science Series Anthology / The Charlie Rose Science Series Anthology (Pfizer, Inc.)(2008).iso / mac / Charlie Rose Science Series Anthology.app / Contents / Resources / movie.swf / scripts / __Packages / mx / controls / MediaController.as < prev    next >
Text File  |  2008-02-01  |  25KB  |  771 lines

  1. class mx.controls.MediaController extends mx.core.UIComponent
  2. {
  3.    static var symbolName = "MediaController";
  4.    static var symbolOwner = mx.controls.MediaController;
  5.    var className = "MediaController";
  6.    static var version = "2.0.2.126";
  7.    var clipParameters = {controllerPolicy:"auto",horizontal:true,activePlayControl:"pause",backgroundStyle:"default"};
  8.    static var MINIMUM_HORIZONTAL_WIDTH = 202;
  9.    static var CLOSED_HORIZONTAL_HEIGHT = 25;
  10.    static var MINIMUM_HORIZONTAL_OPEN_HEIGHT = 63;
  11.    static var LOADBAR_HORIZONTAL_CLOSED_Y = 14;
  12.    static var LOADBAR_HORIZONTAL_OPEN_Y = 24;
  13.    static var MINIMUM_VERTICAL_HEIGHT = 202;
  14.    static var CLOSED_VERTICAL_WIDTH = 25;
  15.    static var MINIMUM_VERTICAL_OPEN_WIDTH = 80;
  16.    static var LOADBAR_VERTICAL_CLOSED_X = 14;
  17.    static var MINIPLAYBAR_VERTICAL_CLOSED_X = 8;
  18.    static var ANIMATION_TIME = 250;
  19.    static var CLOSE_DELAY = 1000;
  20.    static var OPEN_DELAY = 100;
  21.    static var LOCALIZED_FILE = "streamingmediacontroller.xml";
  22.    static var H_BORDER = 8;
  23.    static var V_BORDER = 8;
  24.    var _animating = false;
  25.    var _enabled = true;
  26.    function MediaController()
  27.    {
  28.       super();
  29.    }
  30.    function get lastProgressMediaType()
  31.    {
  32.       return this._lastProgressMediaType;
  33.    }
  34.    function init(Void)
  35.    {
  36.       mx.controls.streamingmedia.Tracer.trace("MediaController.init: start: policy=" + this._controllerPolicy);
  37.       this.initializeParameters();
  38.       mx.controls.streamingmedia.Tracer.trace("MediaController.init: after initializeParameters: policy=" + this._controllerPolicy);
  39.       var _loc3_ = this._width;
  40.       var _loc4_ = this._height;
  41.       super.init();
  42.       if(this._horizontal)
  43.       {
  44.          _loc3_ = Math.max(mx.controls.MediaController.MINIMUM_HORIZONTAL_WIDTH,_loc3_);
  45.          _loc4_ = Math.max(mx.controls.MediaController.MINIMUM_HORIZONTAL_OPEN_HEIGHT,_loc4_);
  46.       }
  47.       else
  48.       {
  49.          _loc3_ = Math.max(mx.controls.MediaController.MINIMUM_VERTICAL_OPEN_WIDTH,_loc3_);
  50.          _loc4_ = Math.max(mx.controls.MediaController.MINIMUM_VERTICAL_HEIGHT,_loc4_);
  51.       }
  52.       this.setSize(_loc3_,_loc4_,true);
  53.       mx.controls.streamingmedia.Tracer.trace("MediaController.init: after setSize " + this.__get__width() + "x" + this.__get__height() + " at (" + this._x + "," + this._y + ")");
  54.       this._priorPolicy = this._controllerPolicy;
  55.       this.createDefaultStrings();
  56.       mx.controls.streamingmedia.Tracer.trace("MediaController.init: Initialized properties:");
  57.       mx.controls.streamingmedia.Tracer.trace("  controllerPolicy=" + this._controllerPolicy);
  58.       mx.controls.streamingmedia.Tracer.trace("  horizontal=" + this._horizontal);
  59.       mx.controls.streamingmedia.Tracer.trace("  activePlayControl=" + this._activePlayControl);
  60.       mx.controls.streamingmedia.Tracer.trace("  backgroundStyle=" + this._backgroundStyle);
  61.       if(this._controllerPolicy == "auto")
  62.       {
  63.          this._isOpen = false;
  64.          this._priorMouseOver = false;
  65.          this._closeId = null;
  66.          this._openId = null;
  67.          Mouse.addListener(this);
  68.          this.gotoAndStop(this.getClosedFrameName());
  69.       }
  70.       else if(this._controllerPolicy == "on")
  71.       {
  72.          this._isOpen = true;
  73.          this.gotoAndStop(this.getOpenFrameName());
  74.       }
  75.       else if(this._controllerPolicy == "off")
  76.       {
  77.          this._isOpen = false;
  78.          this.gotoAndStop(this.getClosedFrameName());
  79.       }
  80.       this._isPlaying = this._activePlayControl == "pause";
  81.       this._playPercent = 0;
  82.       this._playTime = 0;
  83.       this._volume = mx.controls.streamingmedia.StreamingMediaConstants.DEFAULT_VOLUME;
  84.       this.setOpenUpOrLeft(false);
  85.       this.setListeningForPlayheadMoveEvent(true);
  86.       this.tabEnabled = false;
  87.       this.tabChildren = true;
  88.       this.playAtBeginning = false;
  89.       this._screenAccommodator = new mx.controls.streamingmedia.ScreenAccommodator(this);
  90.       this.redraw(true);
  91.    }
  92.    function initializeParameters()
  93.    {
  94.       if(this.__get__horizontal() == null)
  95.       {
  96.          this.__set__horizontal(true);
  97.       }
  98.       if(this.__get__controllerPolicy() == null)
  99.       {
  100.          this.__set__controllerPolicy("auto");
  101.       }
  102.       if(this.__get__backgroundStyle() == null)
  103.       {
  104.          this.__set__backgroundStyle("default");
  105.       }
  106.       if(this.__get__activePlayControl() == null)
  107.       {
  108.          this.__set__activePlayControl("pause");
  109.       }
  110.    }
  111.    function getOpenFrameName()
  112.    {
  113.       return !this._horizontal ? "openVertical" : "openHorizontal";
  114.    }
  115.    function getClosedFrameName()
  116.    {
  117.       return !this._horizontal ? "closedVertical" : "closedHorizontal";
  118.    }
  119.    function draw(Void)
  120.    {
  121.       if(this._isOpen)
  122.       {
  123.          this.gotoAndStop(this.getOpenFrameName());
  124.          this._playBar.draw();
  125.       }
  126.       else
  127.       {
  128.          this.gotoAndStop(this.getClosedFrameName());
  129.          this._miniPlayBar.draw();
  130.       }
  131.       this._loadBar.draw();
  132.       if(this._horizontal)
  133.       {
  134.          this.positionControlsHorizontal();
  135.       }
  136.       else
  137.       {
  138.          this.positionControlsVertical();
  139.       }
  140.       this.drawChrome();
  141.    }
  142.    function positionControlsVertical()
  143.    {
  144.       if(this._isOpen)
  145.       {
  146.          this._volumeControl._x = (this.__get__width() - this._volumeControl._width) / 2;
  147.          this._volumeControl._y = this.__get__height() - this._volumeControl._height - 8;
  148.          this._buttons._x = (this.__get__width() - this._buttons._width) / 2;
  149.          this._buttons._y = this.__get__height() - this._buttons._height - this._volumeControl._height - 16;
  150.          this._playBar._x = (this.__get__width() - this._playBar._width) / 2;
  151.          this._loadBar._x = this._playBar._x + this._playBar._width - 4;
  152.       }
  153.       else
  154.       {
  155.          this._loadBar._x = mx.controls.MediaController.LOADBAR_VERTICAL_CLOSED_X;
  156.          this._miniPlayBar._x = mx.controls.MediaController.MINIPLAYBAR_VERTICAL_CLOSED_X;
  157.       }
  158.    }
  159.    function positionControlsHorizontal()
  160.    {
  161.       if(this._isOpen)
  162.       {
  163.          this._loadBar._y = mx.controls.MediaController.LOADBAR_HORIZONTAL_OPEN_Y;
  164.          this._buttons._x = 8;
  165.          this._buttons._y = this.__get__height() - this._buttons._height - 8;
  166.          this._volumeControl._x = this.__get__width() - this._volumeControl._width - 8;
  167.          this._volumeControl._y = this.__get__height() - this._volumeControl._height - 8;
  168.       }
  169.       else
  170.       {
  171.          this._loadBar._y = mx.controls.MediaController.LOADBAR_HORIZONTAL_CLOSED_Y;
  172.       }
  173.    }
  174.    function drawChrome(wi, he)
  175.    {
  176.       if(wi == null)
  177.       {
  178.          if(this._horizontal)
  179.          {
  180.             wi = this.width;
  181.          }
  182.          else
  183.          {
  184.             wi = !this._isOpen ? mx.controls.MediaController.CLOSED_VERTICAL_WIDTH : this.__get__width();
  185.          }
  186.       }
  187.       if(he == null)
  188.       {
  189.          if(this._horizontal)
  190.          {
  191.             he = !this._isOpen ? mx.controls.MediaController.CLOSED_HORIZONTAL_HEIGHT : this.__get__height();
  192.          }
  193.          else
  194.          {
  195.             he = this.height;
  196.          }
  197.       }
  198.       this._chrome.visible = this.__get__backgroundStyle() == "default";
  199.       this._chrome.showToggles = false;
  200.       this._chrome.setSize(wi,he);
  201.       this._chrome.draw();
  202.    }
  203.    function addSecondChrome(theChrome, closedHeight, openHeight, closedWidth, openWidth, fixedEnd)
  204.    {
  205.       this._secondChrome = theChrome;
  206.       this._secondChromeClosedHeight = closedHeight;
  207.       this._secondChromeOpenHeight = openHeight;
  208.       this._secondChromeClosedWidth = closedWidth;
  209.       this._secondChromeOpenWidth = openWidth;
  210.       this._secondChromeFixedEnd = fixedEnd;
  211.    }
  212.    function removeSecondChrome()
  213.    {
  214.       this._secondChrome = null;
  215.    }
  216.    function get expanded()
  217.    {
  218.       return this._isOpen;
  219.    }
  220.    function onMouseMove()
  221.    {
  222.       var _loc5_ = _root._xmouse;
  223.       var _loc4_ = _root._ymouse;
  224.       var _loc3_ = this.hitTest(_loc5_,_loc4_,true);
  225.       if(_loc3_ && this._closeId != null || this.isNotAnimating())
  226.       {
  227.          clearInterval(this._closeId);
  228.          this._closeId = null;
  229.       }
  230.       if(!_loc3_ && this._openId != null || this.isNotAnimating())
  231.       {
  232.          clearInterval(this._openId);
  233.          this._openId = null;
  234.       }
  235.       if(_loc3_ && !this._isOpen && this._controllerPolicy == "auto" && this._openId == null && !this.isNotAnimating())
  236.       {
  237.          this._openId = setInterval(this,"expand",mx.controls.MediaController.OPEN_DELAY);
  238.       }
  239.       else if(!_loc3_ && this._isOpen && this._controllerPolicy == "auto" && this._closeId == null && !this.isNotAnimating())
  240.       {
  241.          this._closeId = setInterval(this,"contract",mx.controls.MediaController.CLOSE_DELAY);
  242.       }
  243.       this._priorMouseOver = _loc3_;
  244.    }
  245.    function expand(force)
  246.    {
  247.       clearInterval(this._openId);
  248.       this._openId = null;
  249.       if(this._controllerPolicy == "auto" || force)
  250.       {
  251.          this._isOpen = true;
  252.          this._animationStart = getTimer();
  253.          this._animationOpen = true;
  254.          this._priorMouseOver = true;
  255.          this.onEnterFrame = this.animate;
  256.       }
  257.    }
  258.    function contract(force)
  259.    {
  260.       mx.controls.streamingmedia.Tracer.trace("MediaController.contract: force=" + force + ", animating=" + this._animating + ", opening=" + this._animationOpen);
  261.       if(this._animating && !this._animationOpen)
  262.       {
  263.          return undefined;
  264.       }
  265.       clearInterval(this._closeId);
  266.       this._closeId = null;
  267.       if(this._controllerPolicy == "auto" || force)
  268.       {
  269.          this._isOpen = false;
  270.          this._animationStart = getTimer();
  271.          this._animationOpen = false;
  272.          this._priorMouseOver = false;
  273.          this.gotoAndStop(this.getClosedFrameName());
  274.          this.animate();
  275.          this.onEnterFrame = this.animate;
  276.       }
  277.    }
  278.    function animate()
  279.    {
  280.       this._animating = true;
  281.       var _loc4_ = getTimer() - this._animationStart;
  282.       var _loc3_ = Math.min(1,_loc4_ / mx.controls.MediaController.ANIMATION_TIME);
  283.       mx.controls.streamingmedia.Tracer.trace("MediaController.animate: _animationStart=" + this._animationStart + ", elapsed=" + _loc4_ + ", portion=" + _loc3_ + ", ANIMATION_TIME=" + mx.controls.MediaController.ANIMATION_TIME);
  284.       this.sizeMainChrome(_loc3_);
  285.       if(this._secondChrome != null)
  286.       {
  287.          this.sizeSecondChrome(_loc3_);
  288.       }
  289.       this.animateBars(_loc3_);
  290.       if(_loc4_ >= mx.controls.MediaController.ANIMATION_TIME || _global.isLivePreview)
  291.       {
  292.          this.animationDone();
  293.       }
  294.    }
  295.    function animationDone()
  296.    {
  297.       mx.controls.streamingmedia.Tracer.trace("MediaController.animationDone");
  298.       this._animating = false;
  299.       delete this.onEnterFrame;
  300.       this.refreshBars();
  301.       if(this._animationOpen)
  302.       {
  303.          this.gotoAndStop(this.getOpenFrameName());
  304.       }
  305.       this.redraw(true);
  306.    }
  307.    function sizeMainChrome(portion)
  308.    {
  309.       var _loc2_ = this.__get__height();
  310.       var _loc3_ = this.__get__width();
  311.       if(this._horizontal)
  312.       {
  313.          var _loc4_ = (this.__get__height() - mx.controls.MediaController.CLOSED_HORIZONTAL_HEIGHT) * portion;
  314.          if(this._animationOpen)
  315.          {
  316.             _loc2_ = mx.controls.MediaController.CLOSED_HORIZONTAL_HEIGHT + _loc4_;
  317.          }
  318.          else
  319.          {
  320.             _loc2_ = this.__get__height() - _loc4_;
  321.          }
  322.       }
  323.       else
  324.       {
  325.          _loc4_ = (this.__get__width() - mx.controls.MediaController.CLOSED_VERTICAL_WIDTH) * portion;
  326.          if(this._animationOpen)
  327.          {
  328.             _loc3_ = mx.controls.MediaController.CLOSED_VERTICAL_WIDTH + _loc4_;
  329.          }
  330.          else
  331.          {
  332.             _loc3_ = this.__get__width() - _loc4_;
  333.          }
  334.       }
  335.       if(this.isOpenUpOrLeft())
  336.       {
  337.          var _loc6_ = this._chrome.width - _loc3_;
  338.          var _loc5_ = this._chrome.height - _loc2_;
  339.          this._x += _loc6_;
  340.          this._y += _loc5_;
  341.       }
  342.       this.drawChrome(_loc3_,_loc2_);
  343.    }
  344.    function sizeSecondChrome(portion)
  345.    {
  346.       var _loc3_ = undefined;
  347.       var _loc4_ = undefined;
  348.       var _loc2_ = undefined;
  349.       if(this._horizontal)
  350.       {
  351.          _loc4_ = this._secondChromeClosedWidth;
  352.          _loc2_ = (this._secondChromeOpenHeight - this._secondChromeClosedHeight) * portion;
  353.          _loc3_ = !this._animationOpen ? this._secondChromeOpenHeight - _loc2_ : this._secondChromeClosedHeight + _loc2_;
  354.          if(this._secondChromeFixedEnd)
  355.          {
  356.             this._secondChrome._y = this._secondChrome._y - _loc3_ + this._secondChrome.height;
  357.          }
  358.       }
  359.       else
  360.       {
  361.          _loc3_ = this._secondChromeClosedHeight;
  362.          _loc2_ = (this._secondChromeOpenWidth - this._secondChromeClosedWidth) * portion;
  363.          _loc4_ = !this._animationOpen ? this._secondChromeOpenWidth - _loc2_ : this._secondChromeClosedWidth + _loc2_;
  364.          if(this._secondChromeFixedEnd)
  365.          {
  366.             this._secondChrome._x = this._secondChrome._x - _loc4_ + this._secondChrome.width;
  367.          }
  368.       }
  369.       this._secondChrome.setSize(_loc4_,_loc3_);
  370.       this._secondChrome.draw();
  371.    }
  372.    function animateBars(portion)
  373.    {
  374.       var _loc2_ = undefined;
  375.       if(this._horizontal)
  376.       {
  377.          _loc2_ = (mx.controls.MediaController.LOADBAR_HORIZONTAL_OPEN_Y - mx.controls.MediaController.LOADBAR_HORIZONTAL_CLOSED_Y) * portion;
  378.          var _loc8_ = !this._animationOpen ? mx.controls.MediaController.LOADBAR_HORIZONTAL_OPEN_Y - _loc2_ : mx.controls.MediaController.LOADBAR_HORIZONTAL_CLOSED_Y + _loc2_;
  379.          this._loadBar._y = _loc8_;
  380.       }
  381.       else
  382.       {
  383.          var _loc5_ = this._chrome.width / 2;
  384.          _loc2_ = (_loc5_ - mx.controls.MediaController.MINIPLAYBAR_VERTICAL_CLOSED_X) * portion;
  385.          _loc2_ = Math.max(0,_loc2_);
  386.          var _loc9_ = !this._animationOpen ? _loc5_ - _loc2_ : mx.controls.MediaController.MINIPLAYBAR_VERTICAL_CLOSED_X + _loc2_;
  387.          this._miniPlayBar._x = _loc9_;
  388.          this._loadBar._x = this._miniPlayBar._x + this._miniPlayBar._width;
  389.          var _loc3_ = this._loadBar.getClosedHeight();
  390.          var _loc4_ = this._loadBar.getOpenHeight();
  391.          _loc2_ = (_loc3_ - _loc4_) * portion;
  392.          var _loc6_ = !this._animationOpen ? _loc4_ + _loc2_ : _loc3_ - _loc2_;
  393.          this._loadBar.draw(_loc6_);
  394.          this._miniPlayBar.draw(_loc6_);
  395.       }
  396.    }
  397.    function getLoadBar()
  398.    {
  399.       return this._loadBar;
  400.    }
  401.    function refreshBars()
  402.    {
  403.       mx.controls.streamingmedia.Tracer.trace("MediaController.refreshBars: load=" + this._loadPercent + ", play=" + this._playPercent);
  404.       this._loadBar.setCompletionPercentage(this._loadPercent);
  405.       this._playBar.setCompletionPercentage(this._playPercent);
  406.       this._miniPlayBar.setCompletionPercentage(this._playPercent);
  407.    }
  408.    function getLoadPercent()
  409.    {
  410.       return this._loadPercent;
  411.    }
  412.    function getMinimumOpenHeight()
  413.    {
  414.       var _loc2_ = !this._horizontal ? mx.controls.MediaController.MINIMUM_VERTICAL_HEIGHT : mx.controls.MediaController.MINIMUM_HORIZONTAL_OPEN_HEIGHT;
  415.       return _loc2_;
  416.    }
  417.    function getMinimumClosedHeight()
  418.    {
  419.       var _loc2_ = !this._horizontal ? mx.controls.MediaController.MINIMUM_VERTICAL_HEIGHT : mx.controls.MediaController.CLOSED_HORIZONTAL_HEIGHT;
  420.       return _loc2_;
  421.    }
  422.    function getMinimumOpenWidth()
  423.    {
  424.       var _loc2_ = !this._horizontal ? mx.controls.MediaController.MINIMUM_VERTICAL_OPEN_WIDTH : mx.controls.MediaController.MINIMUM_HORIZONTAL_WIDTH;
  425.       return _loc2_;
  426.    }
  427.    function getMinimumClosedWidth()
  428.    {
  429.       var _loc2_ = !this._horizontal ? mx.controls.MediaController.CLOSED_VERTICAL_WIDTH : mx.controls.MediaController.MINIMUM_HORIZONTAL_WIDTH;
  430.       return _loc2_;
  431.    }
  432.    function get controllerPolicy()
  433.    {
  434.       return this._controllerPolicy;
  435.    }
  436.    function set controllerPolicy(aPolicy)
  437.    {
  438.       mx.controls.streamingmedia.Tracer.trace("MediaController.set controllerPolicy: old=" + this._controllerPolicy + ", new=" + aPolicy);
  439.       if(aPolicy == this._controllerPolicy)
  440.       {
  441.          return undefined;
  442.       }
  443.       this._controllerPolicy = aPolicy;
  444.       if(this._controllerPolicy == "on")
  445.       {
  446.          Mouse.removeListener(this);
  447.          if(!this._isOpen)
  448.          {
  449.             this.expand(true);
  450.          }
  451.       }
  452.       else if(this._controllerPolicy == "off")
  453.       {
  454.          Mouse.removeListener(this);
  455.          if(this._isOpen)
  456.          {
  457.             mx.controls.streamingmedia.Tracer.trace("MediaController.set controllerPolicy(off): about to call contract");
  458.             this.contract(true);
  459.          }
  460.       }
  461.       else if(this._controllerPolicy == "auto")
  462.       {
  463.          this._closeId = null;
  464.          this._openId = null;
  465.          Mouse.addListener(this);
  466.          var _loc3_ = this.hitTest(_root._xmouse,_root._ymouse,true);
  467.          if(this._isOpen && !_loc3_)
  468.          {
  469.             mx.controls.streamingmedia.Tracer.trace("MediaController.set controllerPolicy(auto): about to call contract");
  470.             this.contract();
  471.          }
  472.          else if(!this._isOpen && _loc3_)
  473.          {
  474.             this.expand();
  475.          }
  476.       }
  477.    }
  478.    function get horizontal()
  479.    {
  480.       return this._horizontal;
  481.    }
  482.    function set horizontal(isHoriz)
  483.    {
  484.       if(isHoriz != this._horizontal)
  485.       {
  486.          this._horizontal = isHoriz;
  487.          var _loc2_ = this.__get__height();
  488.          var _loc3_ = this.__get__width();
  489.          if(isHoriz)
  490.          {
  491.             _loc2_ = Math.max(_loc2_,mx.controls.MediaController.MINIMUM_HORIZONTAL_WIDTH);
  492.             _loc3_ = Math.max(_loc3_,mx.controls.MediaController.MINIMUM_HORIZONTAL_OPEN_HEIGHT);
  493.          }
  494.          else
  495.          {
  496.             _loc2_ = Math.max(_loc2_,mx.controls.MediaController.MINIMUM_VERTICAL_OPEN_WIDTH);
  497.             _loc3_ = Math.max(_loc3_,mx.controls.MediaController.MINIMUM_VERTICAL_HEIGHT);
  498.          }
  499.          this.setSize(_loc2_,_loc3_);
  500.          this.invalidate();
  501.       }
  502.       else
  503.       {
  504.          this._horizontal = isHoriz;
  505.       }
  506.    }
  507.    function get volume()
  508.    {
  509.       return this._volume;
  510.    }
  511.    function set volume(vol)
  512.    {
  513.       this._volume = vol;
  514.       this._volumeControl.getHandle().setVolume(vol);
  515.    }
  516.    function get backgroundStyle()
  517.    {
  518.       return this._backgroundStyle;
  519.    }
  520.    function set backgroundStyle(aStyle)
  521.    {
  522.       this._backgroundStyle = aStyle;
  523.       this.drawChrome();
  524.    }
  525.    function broadcastEvent(eventType, detailArg)
  526.    {
  527.       var _loc2_ = {type:eventType,target:this,detail:detailArg};
  528.       if(eventType == "volume")
  529.       {
  530.          this._volume = detailArg;
  531.       }
  532.       this.dispatchEvent(_loc2_);
  533.    }
  534.    function handleEvent(ev)
  535.    {
  536.       if(ev.type == "change")
  537.       {
  538.          this.playAtBeginning = false;
  539.          if(this.isListeningForPlayheadMoveEvent())
  540.          {
  541.             this.handleChangeEvent(ev);
  542.          }
  543.       }
  544.       else if(ev.type == "progress")
  545.       {
  546.          this.handleProgressEvent(ev);
  547.       }
  548.       else if(ev.type == "complete")
  549.       {
  550.          this.handleCompleteEvent(ev);
  551.       }
  552.       else if(ev.type == "scrubbing")
  553.       {
  554.          this.handleScrubbingEvent(ev);
  555.       }
  556.       else
  557.       {
  558.          this.handleUnrecognizedEvent(ev);
  559.       }
  560.    }
  561.    function isListeningForPlayheadMoveEvent()
  562.    {
  563.       return this._listenForPlayheadMoveEvent;
  564.    }
  565.    function setListeningForPlayheadMoveEvent(listen)
  566.    {
  567.       this._listenForPlayheadMoveEvent = listen;
  568.    }
  569.    function isNotAnimating()
  570.    {
  571.       return this._notAnimating;
  572.    }
  573.    function setNotAnimating(still)
  574.    {
  575.       this._notAnimating = still;
  576.    }
  577.    function get activePlayControl()
  578.    {
  579.       return this._activePlayControl;
  580.    }
  581.    function set activePlayControl(aControl)
  582.    {
  583.       this._activePlayControl = aControl;
  584.    }
  585.    function get playing()
  586.    {
  587.       return this.isPlaying();
  588.    }
  589.    function set playing(playFlag)
  590.    {
  591.       this.setPlaying(playFlag);
  592.    }
  593.    function isPlaying()
  594.    {
  595.       return this._isPlaying;
  596.    }
  597.    function setPlaying(playFlag)
  598.    {
  599.       this._isPlaying = playFlag;
  600.       this._playBar.setIsPlaying(playFlag);
  601.       if(playFlag)
  602.       {
  603.          this._buttons.playPauseButtons.showPauseButton();
  604.       }
  605.       else
  606.       {
  607.          this._buttons.playPauseButtons.showPlayButton();
  608.       }
  609.    }
  610.    function handleChangeEvent(ev)
  611.    {
  612.       var _loc2_ = ev.target;
  613.       this._playTime = _loc2_.playheadTime;
  614.       var _loc3_ = _loc2_.__get__totalTime();
  615.       this._playPercent = 100 * this._playTime / _loc3_;
  616.       if(this._isOpen)
  617.       {
  618.          this._playBar.setCompletionPercentage(this._playPercent);
  619.          this._playBar.setTime(this._playTime);
  620.       }
  621.       else
  622.       {
  623.          this._miniPlayBar.setCompletionPercentage(this._playPercent);
  624.       }
  625.    }
  626.    function handleProgressEvent(ev)
  627.    {
  628.       if(ev.target.isRtmp(ev.target.contentPath))
  629.       {
  630.          this._loadPercent = 100;
  631.       }
  632.       else
  633.       {
  634.          var _loc4_ = ev.target.bytesLoaded;
  635.          var _loc3_ = ev.target.bytesTotal;
  636.          this._loadPercent = 100 * _loc4_ / _loc3_;
  637.       }
  638.       this.refreshBars();
  639.       this._lastProgressMediaType = ev.target.mediaType;
  640.       this.evaluateToEnd();
  641.    }
  642.    function evaluateToEnd()
  643.    {
  644.       if(!this._isOpen)
  645.       {
  646.          return undefined;
  647.       }
  648.       var _loc2_ = false;
  649.       if(this._loadPercent >= 99 && this.__get__enabled())
  650.       {
  651.          if(this._lastProgressMediaType == "MP3")
  652.          {
  653.             _loc2_ = true;
  654.          }
  655.          else if(this._lastProgressMediaType == "FLV" && !mx.controls.streamingmedia.StreamingMediaConstants.DISABLE_FLV_TOEND)
  656.          {
  657.             _loc2_ = true;
  658.          }
  659.       }
  660.       this._buttons.toEndButton.enabled = _loc2_;
  661.    }
  662.    function handleCompleteEvent(ev)
  663.    {
  664.       if(!this.isScrubbing() && !this._animating)
  665.       {
  666.          var _loc2_ = ev.target;
  667.          this._playTime = _loc2_.totalTime;
  668.          this._playPercent = 100;
  669.          if(this._isOpen)
  670.          {
  671.             this._playBar.setCompletionPercentage(this._playPercent);
  672.             this._playBar.setTime(this._playTime);
  673.          }
  674.          else
  675.          {
  676.             this._miniPlayBar.setCompletionPercentage(this._playPercent);
  677.          }
  678.          this.setPlaying(false);
  679.          mx.controls.streamingmedia.Tracer.trace("MediaController.handleCompleteEvent: playAtBeginning=true");
  680.          this.playAtBeginning = true;
  681.       }
  682.    }
  683.    function handleScrubbingEvent(ev)
  684.    {
  685.       this._listenForPlayheadMoveEvent = !ev.detail;
  686.    }
  687.    function handleUnrecognizedEvent(ev)
  688.    {
  689.       mx.controls.streamingmedia.Tracer.trace("received an unrecognized event of type " + ev.type + " with target " + ev.target);
  690.    }
  691.    function createDefaultStrings()
  692.    {
  693.       this._strings = new Object();
  694.       this._strings.paused = "PAUSED";
  695.       this._strings.streaming = "STREAMING";
  696.    }
  697.    function getLocalizedString(id)
  698.    {
  699.       var _loc2_ = this._strings[id];
  700.       return _loc2_;
  701.    }
  702.    function get playTime()
  703.    {
  704.       return this._playTime;
  705.    }
  706.    function set playTime(aTime)
  707.    {
  708.       this._playTime = aTime;
  709.    }
  710.    function get playPercent()
  711.    {
  712.       return this._playPercent;
  713.    }
  714.    function set playPercent(aPercent)
  715.    {
  716.       this._playPercent = aPercent;
  717.    }
  718.    function isOpenUpOrLeft()
  719.    {
  720.       return this._openUpOrLeft;
  721.    }
  722.    function setOpenUpOrLeft(is)
  723.    {
  724.       this._openUpOrLeft = is;
  725.    }
  726.    function associateDisplay(d)
  727.    {
  728.       d.associateController(this);
  729.    }
  730.    function setSize(w, h, noEvent)
  731.    {
  732.       super.setSize(w,h,noEvent);
  733.       this.invalidate();
  734.    }
  735.    function get enabled()
  736.    {
  737.       return this._enabled;
  738.    }
  739.    function set enabled(is)
  740.    {
  741.       mx.controls.streamingmedia.Tracer.trace("MediaController.set enabled to " + is);
  742.       this._enabled = is;
  743.       this._buttons.toStartButton.enabled = is;
  744.       this._buttons.toEndButton.enabled = is;
  745.       this._buttons.playPauseButtons.enabled = is;
  746.       this._volumeControl._muteButton.muteSimpleButton.enabled = is;
  747.       this._volumeControl._loudButton.loudSimpleButton.enabled = is;
  748.       this._playBar.__set__enabled(is);
  749.       this._volumeControl.getHandle().__set__enabled(is);
  750.       if(is)
  751.       {
  752.          if(this._priorPolicy != null)
  753.          {
  754.             this.__set__controllerPolicy(this._priorPolicy);
  755.          }
  756.       }
  757.       else
  758.       {
  759.          this._priorPolicy = this.controllerPolicy;
  760.          if(this.__get__controllerPolicy() == "auto")
  761.          {
  762.             this.__set__controllerPolicy("off");
  763.          }
  764.       }
  765.    }
  766.    function isScrubbing()
  767.    {
  768.       return this._playBar.isScrubbing();
  769.    }
  770. }
  771.